package mcsm.OperationCenter;

import mcsm.DataBaseIntegration.DataBaseConnect;
import mcsm.DataBaseIntegration.EditStaffOperation;
import mcsm.DataBaseIntegration.EditVIPConnect;
import mcsm.DataBaseInterface.Connector;
import mcsm.Model.Person;
import mcsm.Model.Staff;
import mcsm.Model.VIP;

public class SelfEdit {
	DataBaseConnect database;
	Connector connector;
	private Person person;
	
	public SelfEdit(Person person){
		this.person=person;
	}
	
	public SelfEdit(){}
	
	public void set(Person person){
		this.person=person;
	}
	
	public void setPassword(String password){
		person.setPassword(password);
	}
	
	public void setName(String name){
		person.setName(name);
	}
	
	public void setPhone(String phone){
		if(person instanceof VIP){
			((VIP)(person)).setPhone(phone);
		}
	}
	
	public void submit(){
		database=DataBaseConnect.getDatabase();
		if(person instanceof VIP){
			connector=new EditVIPConnect((VIP)person);
		} else {
			connector=new EditStaffOperation((Staff)person);
		}
		database.connect(connector);
	}
}
